Overloaded operation and conversion

规范
思考 thinkong
改进 improvement
说明 specification

When an overloaded operator is a member function, this is bound to the left-hand operand. Member operator functions have one less (explicit)parameter than the number of operands.When an overloaded operator is a member function, this is bound to the left-hand operand. Member operator functions have one less (explicit) parameter than the number of operands.

deciding whether to make an operator a member or an ordinary nonmember function:
• The assignment (=), subscript ([]), call (()), and member access arrow (->)
operators must be defined as members.
• The compound-assignment operators ordinarily ought to be members. However,
unlike assignment, they are not required to be members.
• Operators that change the state of their object or that are closely tied to their
given type—such as increment, decrement, and dereference—usually should be
members.
• Symmetric operators—those that might convert either operand, such as the
arithmetic, equality, relational, and bitwise operators—usually should be defined
as ordinary nonmember functions.

IO Operators Must Be Nonmember Functions IO operators usually must be declared as friends